package asteroids.model.programs.parsing.expressions;

import java.util.Map;

import asteroids.model.CollisionObject;
import asteroids.model.Ship;

public class GetVY extends EntityExpression {
	public GetVY(E e){
		super(e);
	}
	public Object getContent(Map<String,E> map, CollisionObject givenCollisionObject){
		try{
			if(getExpression().getContent(map, givenCollisionObject) instanceof CollisionObject){
		CollisionObject collisionObject = (CollisionObject) getExpression().getContent(map, givenCollisionObject);
		return collisionObject.getYVelocity();
		}
			if(givenCollisionObject.isShip()){
				Ship ship = (Ship)givenCollisionObject;
				ship.getProgram().setMistake();
			}
			System.out.println("There is something wrong with you're program, please re-enter a new one.");
			return null;
		}
		catch(NullPointerException exc){
			if(givenCollisionObject.isShip()){
				Ship ship = (Ship)givenCollisionObject;
				ship.getProgram().setMistake();
			}
			System.out.println("There is something wrong with you're program, please re-enter a new one.");
			return null;
		}
	}
}
